﻿using Customer.Domain;
using Customer.Read.API.Applcation.Command.MeetCommand;
using Customer.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.IdentityModel.Tokens.Jwt;

namespace Customer.Read.API.Controllers
{
    /// <summary>
    /// 应付控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MeetController : ControllerBase
    {
        private readonly IMediator _mediator;

        public MeetController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 显示应付列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
       public async Task<ApiResult<AccountsPage>> GetMeetList([FromQuery]SelectMeetCommand command)
        {
            ApiResult<AccountsPage> result = new ApiResult<AccountsPage>();
            try
            {
                var sid = HttpContext.User.FindFirst(JwtRegisteredClaimNames.Sid)?.Value;//获取公司id
                command.Office_Id = sid;
                result.Data = await _mediator.Send(command);
            }
            catch (Exception ee)
            {
                result.Code = -1;
                result.Message = ee.Message;
                throw;
            }
            return result;
        }
        /// <summary>
        /// 显示应付列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Accounts>> FanMeetList([FromQuery] FanMeetCommand command)
        {
            ApiResult<Accounts> result = new ApiResult<Accounts>();
            try
            {
                result.Data = await _mediator.Send(command);
            }
            catch (Exception ee)
            {
                result.Code = -1;
                result.Message = ee.Message;
                throw;
            }
            return result;
        }








    }
}
